
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JS测试显示器分辨率</title>
</head>
<body>
<div style="width:1cm;" id="screen"></div>
<SCRIPT LANGUAGE="JavaScript">
if(navigator.userAgent.indexOf("iPhone") != -1 ){
document.write('此机型是:iphone<br/>');
}else if( navigator.userAgent.indexOf("Android") != -1){
document.write('此机型是:Android<br/>');
}else{
document.write('此机型是:windows<br/>');
}
document.write('您的显示器分辨率为:\n' + screen.width + '*' + screen.height + ' pixels<br/>');
var ww = document.getElementById("screen").offsetWidth;
var w = screen.width/ww;
var h = screen.height/ww
var r = Math.round(Math.sqrt(w*w + h*h) / 2.54);
document.write(' 您的显示器尺寸为:\n' + w.toFixed(1) + '*' + h.toFixed(1) + ' cm, '+ r +'寸<br/>');
</SCRIPT>
</body>
</html>